package com.yuandian.management.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuandian.api.management.entity.ConfExclusiveIndicator;
import com.yuandian.bpm.common.data.datascope.BpmBaseMapper;
import com.yuandian.management.vo.ExclusiveIndicatorVo;
import com.yuandian.management.vo.IndicatorSyncResourceVo;
import com.yuandian.management.vo.IndicatorsSyncParams;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;


/**
 * 专属指标表-Mapper接口
 * @author zfsn
 * @date 2023-3-22
 */
@Mapper
public interface ConfExclusiveIndicatorMapper extends BpmBaseMapper<ConfExclusiveIndicator> {

	/**
	 * 分页查询
	 *
	 * @param confExclusiveIndicator 筛选条件
	 * @return 通用返回对象
	 */
    Page<ExclusiveIndicatorVo> listPage(Page<ConfExclusiveIndicator> objectPage, @Param("params") ConfExclusiveIndicator confExclusiveIndicator);

    List<ConfExclusiveIndicator> selectByResourceCodes(@Param("list") List<String> list);


	/**
	 * 通过主键查询数据
	 *
	 * @param resourceCode 业务资源
	 * @return 通用返回对象
	 */
	ConfExclusiveIndicator getExclusiveIndicatorByResourceCode(@Param("resourceCode") String resourceCode);

	void updateByResourceCode(@Param("params") ConfExclusiveIndicator confExclusiveIndicator);

	/**
	 * 根据业务资源获取系统,业务名称，步骤名称信息
	 *
	 * @param confExclusiveIndicator
	 * @return
	 */
	Page<Map<String, String>> getSystemAndBusinessAndStepNameByResourceCode(Page<Object> objectPage,@Param("params") ConfExclusiveIndicator confExclusiveIndicator);

	/**
	 * 根据业务资源查询网端信息
	 *
	 * @param confExclusiveIndicator
	 */
	Page<Map<String, String>> getSegmentInfoByResourceCode(Page<Object> objectPage, @Param("params") ConfExclusiveIndicator confExclusiveIndicator);

	/**
	 * 查询类型为子资源的可同步或已同步的业务服务资源列表
	 * @param params 专属指标同步请求参数
	 * @return 通用分页对象
	 */
	List<IndicatorSyncResourceVo> queryChildSyncResource(Page<IndicatorSyncResourceVo> page, @Param("params") IndicatorsSyncParams params);


	//	根据网端id查询端到端关联表，非首端的可同步或已同步的业务服务资源列表
	List<IndicatorSyncResourceVo> querySegmentSyncResource(Page<IndicatorSyncResourceVo> page, @Param("params") IndicatorsSyncParams params);

	List<IndicatorSyncResourceVo> queryBusinessSyncResource(@Param("params") IndicatorsSyncParams params, Page<IndicatorSyncResourceVo> page);

	/**
	 * 查询类型为父资源的可同步或已同步的业务服务资源列表
	 * @param params 专属指标同步请求参数
	 * @return 指标同步服务资源列表vo对象集合
	 */
	List<IndicatorSyncResourceVo> queryParentSyncResource(
			@Param("params") IndicatorsSyncParams params, Page<IndicatorSyncResourceVo> page);



	/**
	 * 查询类型为同一网端(首端)的可同步或已同步的业务服务资源列表
	 * @param params 专属指标同步请求参数
	 * @return 指标同步服务资源列表vo对象集合
	 */
	List<IndicatorSyncResourceVo> queryHeadSegmentSyncResource(
			@Param("params") IndicatorsSyncParams params, Page<IndicatorSyncResourceVo> page);


	/**
	 * 根据ID集合与资源编码集合删除资源编码对应code的专属指标
	 * @param idList 专属指标ids
	 * @param resourceCodeList 服务资源编码集合
	 * @return 影响行数
	 */
	int deleteByIdListAndResourceCode(
			@Param("idList") List<Integer> idList, @Param("resourceCodeList") List<String> resourceCodeList);

    void deleteSyncExclusiveIndicators(Map<String, Object> map);

    List<ConfExclusiveIndicator> list(@Param("params") ConfExclusiveIndicator confExclusiveIndicator);
}
